<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
  <title>seven网上商城</title>
  <link href="${pageContext.request.contextPath}/css/common.css" rel="stylesheet" type="text/css"/>
  <link href="${pageContext.request.contextPath}/css/product.css" rel="stylesheet" type="text/css"/>
  <script type="text/javascript">
    //传递当前页和cid
    function gotopage(page,cid){
      window.location.href="${pageContext.request.contextPath}/findByCid.do?page="+page+"&cid="+cid;
    }
  </script>
  <link rel="shortcut icon" href="${pageContext.request.contextPath}/images/tit.ico" type="image/x-icon" />
  <script type="text/javascript" src="${pageContext.request.contextPath}/js/jsized.snow.min.js"></script>
  <script>
    createSnow('', 60);
  </script>
</head>
<body>
<div class="container header">
  <div class="span5">
    <div class="logo">
      <a href="http://localhost:8080/mango/">
        <img src="${pageContext.request.contextPath}/image/r___________renleipic_01/logo2.gif" alt="seven商城"/>
      </a>
    </div>
  </div>
  <div class="span9">
    <div class="headerAd">
      <img src="${pageContext.request.contextPath}/image/header.jpg" width="320" height="50" alt="正品保障" title="正品保障"/>
    </div>	</div>
  <%@ include file="menu.jsp" %>

</div>
<div class="container productList">
  <div class="span6">
    <div class="hotProductCategory">
      <c:forEach var="c" items="${clist}">
        <dl>
          <dt>
            <a href="${pageContext.request.contextPath}/findByCid.do?cid=${c.cid}&page=1">${c.cname}</a>
          </dt>
          <c:forEach var="cs" items="${c.secondList}">
            <dd>
              <a href="${pageContext.request.contextPath}/findByCsid.do?csid=${cs.csid}&page=1">${cs.csname}</a>
            </dd>
          </c:forEach>
        </dl>
      </c:forEach>
    </div>
  </div>
  <div class="span18 last">
    <%--

      <form id="productForm" action="${pageContext.request.contextPath}/image/蔬菜 - Powered By Mango Team.htm" method="get">
        <input type="hidden" id="brandId" name="brandId" value=""/>
        <input type="hidden" id="promotionId" name="promotionId" value=""/>
        <input type="hidden" id="orderType" name="orderType" value=""/>
        <input type="hidden" id="pageNumber" name="pageNumber" value="1"/>
        <input type="hidden" id="pageSize" name="pageSize" value="20"/>
      </form>
        --%>
    <div id="result" class="result table clearfix">
      <ul>
        <c:forEach  var="p" items="${pageInfo.list}">
          <li>
            <a href="${pageContext.request.contextPath}/productFindByPid.do?pid=${p.pid}">
              <img src="${pageContext.request.contextPath}/${p.image}" width="170" height="170"  style="display:inline-block;"/>
              <span class="pname">
                  ${p.pname}
              </span>

              <span class="price" style='color:#ff3300;'>
												商城价： ￥${p["shop_price"]}
											</span>

            </a>
          </li>
        </c:forEach>
      </ul>
    </div>

    <%--显示分页 =====================================================================--%>
    <%--页码处理--%>
    <c:choose>
      <%--当显示页码时,总页码<=10时，全部显示--%>
      <c:when test="${page.pageCount<=10}">
        <c:set var="begin" value="1"/>
        <c:set var="end" value="${page.pageCount}"/>
      </c:when>
      <%--当总页码>10时,只显示10页--%>
      <c:otherwise>
        <c:set var="begin" value="${page.page-5}"/>
        <c:set var="end" value="${page.page+4}"/>
        <%--当前页-5后的begin<1时：begin=1, end=10--%>
        <c:if test="${begin<1}">
          <c:set var="begin" value="1"/>
          <c:set var="end" value="10"/>
        </c:if>
        <%--当前页+4后的end>总页数时:begin=总页数-9,end=总页数--%>
        <c:if test="${end>page.pageCount}">
          <c:set var="begin" value="${page.pageCount-9}"/>
          <c:set var="end" value="${page.pageCount}"/>
        </c:if>
      </c:otherwise>
    </c:choose>

    <%--页码显示--%>
    <div class="pagination">
      <span style="color:#666;">第${page.page}页/共${page.pageCount}页</span>
      <c:if test="${page.page ne 1}">
        <%--跳转到首页 --%>
        <a href="javascript:gotopage(1,${cid})" class="firstPage">&nbsp;</a>

        <%--上一页 --%>
        <a href="javascript:gotopage(${page.page-1},${cid})" class="previousPage">&nbsp;</a>
      </c:if>
      <c:forEach var="num" begin="${begin}" end="${end}">
        <c:choose>
          <c:when test="${num eq page.page}">
            <span class="currentPage">${num}</span>
          </c:when>
          <c:otherwise>
            <a href="javascript:gotopage(${num},${cid})">${num}</a>
          </c:otherwise>
        </c:choose>
      </c:forEach>

      <c:if test="${page.page ne page.pageCount}">
        <%--下一页 --%>
        <a href="javascript:gotopage(${page.page+1},${cid})" class="nextPage">&nbsp;</a>

        <%--跳转到尾页 --%>
        <a href="javascript:gotopage(${page.pageCount},${cid})"class="lastPage">&nbsp;</a>
      </c:if>
    </div>


  </div>
</div>
<%--尾部 --%>
<%@ include file="bottom.jsp" %>
</body>
</html>
